﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WiTeach.CourseManagement.View;
using WiTeach.ClassManagement.View;
using System.Diagnostics;

namespace WiTeach.ClassManagement.View
{
    /// <summary>
    /// ClassPractiseIndex.xaml 的交互逻辑
    /// </summary>
    public partial class ClassPractiseIndex : Page
    {
        public int lessonID;
        public int classHourID;
        public ClassPractiseIndex()
        {
            InitializeComponent();
            // 修改页面背景主题
            ImageBrush brush = new ImageBrush();
            brush.Stretch = Stretch.Fill;
            brush.ImageSource = new BitmapImage(new Uri(App.backgroundImage, UriKind.RelativeOrAbsolute));
            this.Background = brush;
        }
        public ClassPractiseIndex(string className,int lessonID, int classHourID)
        {
            InitializeComponent();
            // 修改页面背景主题
            ImageBrush brush = new ImageBrush();
            brush.Stretch = Stretch.Fill;
            brush.ImageSource = new BitmapImage(new Uri(App.backgroundImage, UriKind.RelativeOrAbsolute));
            this.Background = brush;
            this.practisePageTitle.Content = className+"——做一做";
            this.lessonID = lessonID;
            this.classHourID = classHourID;
        }


        #region 导航按钮事件实现
        private void backPreLevel(object sender, RoutedEventArgs e)
        {
            this.NavigationService.GoBack();
        }

        private void backHome(object sender, RoutedEventArgs e)
        {
            CourseIndex courseIndex = new CourseIndex();
            this.NavigationService.Navigate(courseIndex);

        }

        #endregion

        private void ProgramWriting(object sender, RoutedEventArgs e)
        {
            // 跳转至程序编写页面
            ProgramWriting programWritingPage = new ProgramWriting(lessonID, classHourID);
            this.NavigationService.Navigate(programWritingPage);
        }

        private void ProgramRecording(object sender, RoutedEventArgs e)
        {
            ProgramRecording programRecording = new ProgramRecording(lessonID, classHourID);
            this.NavigationService.Navigate(programRecording);
        }

        private void TeachingDemonstration(object sender, RoutedEventArgs e)
        {
            TeachingDemonstration teachingPage = new TeachingDemonstration(lessonID, classHourID);
            this.NavigationService.Navigate(teachingPage);
        }

        private void classpractise_backmain_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 66;
            image.Width = 104;
        }
        private void classpractise_backmain_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 60;
            image.Width = 98;
        }
        private void classpractise_back_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 66;
            image.Width = 104;
        }
        private void classpractise_back_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 60;
            image.Width = 98;
        }

        private void classpractise_choice_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 250;
            image.Width = 256;
        }
        private void classpractise_choice_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 244;
            image.Width = 250;
        }

        private void classpractise_keil_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 56;
            image.Width = 59;
        }
        private void classpractise_keil_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 46;
            image.Width = 49;
        }
        private void classpractise_arduino_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 54;
            image.Width = 60;
        }
        private void classpractise_arduino_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 48;
            image.Width = 54;
        }
        private void classpractise_flymcu_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 52;
            image.Width = 60;
        }
        private void classpractise_flymcu_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 48;
            image.Width = 54;
        }
        private void classpractise_progisp_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 52;
            image.Width = 59;
        }
        private void classpractise_progisp_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 48;
            image.Width = 54;
        }
        private void classpractise_s4a_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 53;
            image.Width = 59;
        }
        private void classpractise_s4a_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 48;
            image.Width = 54;
        }
        private void uv4_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string KEIL_Lic_path = System.Configuration.ConfigurationManager.AppSettings["app_KEIL_Lic"];
                Process uv4 = new Process();
                uv4.StartInfo.FileName = KEIL_Lic_path;
                uv4.Start();
                uv4.WaitForExit();
                uv4.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            //   System.Diagnostics.Process.Start(@KEIL_Lic_path);
        }

        private void progisp_Click(object sender, RoutedEventArgs e)
        {
            string progisp_path = System.Configuration.ConfigurationManager.AppSettings["app_progisp"];


            //     System.Diagnostics.Process.Start(@progisp_path);
            try
            {
                Process progisp = new Process();
                progisp.StartInfo.FileName = progisp_path;
                progisp.Start();
                progisp.WaitForExit();
                progisp.Close();
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

        }

        private void flymcu_Click(object sender, RoutedEventArgs e)
        {
            string flymcu_path = System.Configuration.ConfigurationManager.AppSettings["app_flymcu"];
            //          System.Diagnostics.Process.Start(@flymcu_path);
            try
            {
                Process flymcu = new Process();
                flymcu.StartInfo.FileName = flymcu_path;
                flymcu.Start();
                flymcu.WaitForExit();
                flymcu.Close();
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

        }

        private void arduino_Click(object sender, RoutedEventArgs e)
        {
            string arduino_path = System.Configuration.ConfigurationManager.AppSettings["app_arduino"];
            //        System.Diagnostics.Process.Start(@arduino_path);
            try
            {
                Process arduino = new Process();
                arduino.StartInfo.FileName = arduino_path;
                arduino.Start();
                arduino.WaitForExit();
                arduino.Close();
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

        }
        private void scratch_Click(object sender, RoutedEventArgs e)
        {
            string scratch_path = System.Configuration.ConfigurationManager.AppSettings["app_scratch"];
            //        System.Diagnostics.Process.Start(@arduino_path);
            try
            {
                Process scratch = new Process();
                scratch.StartInfo.FileName = scratch_path;
                scratch.Start();
                scratch.WaitForExit();
                scratch.Close();
                GC.Collect();
            }
            catch (Exception)
            {
            }

        }
        private void course_scratch_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 54;
            image.Width = 60;
        }
        private void course_scratch_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 48;
            image.Width = 54;
        }
        private void sa_Click(object sender, RoutedEventArgs e)
        {
            string sa_path = System.Configuration.ConfigurationManager.AppSettings["app_S4A15"];
            Process sa = new Process();
            try
            {
                sa.StartInfo.FileName = sa_path;
                Console.WriteLine("sa_path" + sa_path);
                sa.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                sa.Start();
                sa.WaitForExit();
                sa.Close();
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

        private void anaconda_Click(object sender, RoutedEventArgs e)
        {
            string anaconda_path = System.Configuration.ConfigurationManager.AppSettings["app_anaconda"];
            //        System.Diagnostics.Process.Start(@arduino_path);
            try
            {
                Process scratch = new Process();
                scratch.StartInfo.FileName = anaconda_path;
                scratch.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                scratch.Start();
                scratch.WaitForExit();
                scratch.Close();
                GC.Collect();
            }
            catch (Exception)
            {
            }

        }
    }
}
